package com.ftg.learn.framework.mybatis.javabase.mapper;

import com.ftg.learn.framework.mybatis.javabase.entity.StudentEntity;
import com.ftg.learn.framework.mybatis.javabase.mapper.sqlbuilder.StudentSqlBuilder;
import org.apache.ibatis.annotations.*;

import java.util.Hashtable;
import java.util.List;

/**
 * 处理sql
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/9/4 上午9:24
 */
@Mapper
public interface StudentMapper {

//    @Select("<script>" +
//            "select * from student" +
//            "   <where>"+
//            "       <if test=\"stu_sex != null\">" +
//            "           ssex = #{stu_sex}" +
//            "       </if>" +
//            "       <if test=\"stu_name != null\">" +
//            "          and sname like concat(#{stu_name},'%')" +
//            "       </if>" +
//            "   </where>"+
//            "</script>")
    List<StudentEntity> showListWithParameter(@Param("stu_sex") String stu_sex, @Param("stu_name") String stu_name);


    @Select("select * from student")
    List<StudentEntity> showall();


    /**
     * sql构建器  通过一个向导注解，让当前方法 的mapper映射从@ 和 xml里移除，去java里面
     * @Provider
     * @SelectProvider
     * @insertProvider
     * @param stu_sex
     * @param stu_name
     * @return
     */
    @SelectProvider(value = StudentSqlBuilder.class,method = "studentSelect")
    List<StudentEntity> showListWithParameter1(@Param("stu_sex") String stu_sex, @Param("stu_name") String stu_name);


    //config : Properties -- 属性类文件 abc.properties

    // 1 : properties 属性文件的使用以及功能  应用场景
    // 2 ：mybatis 设计当中

    // 3 : CRUD 完全使用 查询向导 @SelectProvider @

}
